package dao

import (
	"context"
	"mall-portalv2/internal/model"
)

type T struct {
	CrowdFundingId      int `json:"crowd_funding_id"`
	CrowdFundingThaliId int `json:"crowd_funding_thali_id"`
	ProductSkuId        int `json:"product_sku_id"`
	ProductId           int `json:"product_id"`
}

func (d *Dao) QueryProductAndCordFunding(ctx context.Context, CrowdFundingId, CrowdFundingThaliId, ProductSkuId, ProductId int64) (model.ViewProductCrowdFundingDetail, error) {
	tb := model.ViewProductCrowdFundingDetail{}
	result := model.ViewProductCrowdFundingDetail{}

	if err := d.db.WithContext(ctx).Table(tb.TableName()).Where("crowd_funding_id = ? AND crowd_funding_thali_id = ? AND product_sku_id = ? AND product_id = ?", CrowdFundingId, CrowdFundingThaliId, ProductSkuId, ProductId).First(&result).Error; err != nil {
		return result, err
	}
	return result, nil
}
